package com.usian.admin.controller.v1;

import com.usian.admin.service.AdChannelService;
import com.usian.apis.admin.AdChannelControllerApis;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Auther：DONG on 2021/11/2
 **/
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController implements AdChannelControllerApis {

    @Autowired
    private AdChannelService adChannelService;


    @Override
    @PostMapping("/list")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto) {


        return adChannelService.findByNameAndPage(dto);
    }

    @Override
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody AdChannel adChannel) {
        return adChannelService.insert(adChannel);
    }

    @Override
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return adChannelService.updateAdChannel(adChannel);
    }

    @GetMapping("/del/{id}")
    @Override
    public ResponseResult delete(@PathVariable Integer id) {

        return adChannelService.delete(id);
    }
}
